﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using VAdvantage.Classes;
using VAdvantage.Model;
using VAdvantage.Process; using VAdvantage.ProcessEngine;
using VAdvantage.Utility;
using VAdvantage.DataBase;
using VAdvantage.Logging;
using System.IO;

namespace VAdvantage.Model
{
    public class X_AD_TextTemplate : PO
    {
        public X_AD_TextTemplate(Context ctx, int AD_TextTemplate_ID, String trxName)
            : base(ctx, AD_TextTemplate_ID, trxName)
        {
            /** if (AD_TextTemplate_ID == 0)
            {
            SetAD_TextTemplate_ID (0);
            }
             */
        }
        public X_AD_TextTemplate(Ctx ctx, int AD_TextTemplate_ID, String trxName)
            : base(ctx, AD_TextTemplate_ID, trxName)
        {
            /** if (AD_TextTemplate_ID == 0)
            {
            SetAD_TextTemplate_ID (0);
            }
             */
        }
        /** Load Constructor 
        @param ctx context
        @param rs result set 
        @param trxName transaction
        */
        public X_AD_TextTemplate(Context ctx, DataRow rs, String trxName)
            : base(ctx, rs, trxName)
        {
        }
        /** Load Constructor 
        @param ctx context
        @param rs result set 
        @param trxName transaction
        */
        public X_AD_TextTemplate(Ctx ctx, DataRow rs, String trxName)
            : base(ctx, rs, trxName)
        {
        }
        /** Load Constructor 
        @param ctx context
        @param rs result set 
        @param trxName transaction
        */
        public X_AD_TextTemplate(Ctx ctx, IDataReader dr, String trxName)
            : base(ctx, dr, trxName)
        {
        }
        /** Serial Version No */
        static long serialVersionUID = 27555010991457L;
        /** Last Updated Timestamp 5/3/2010 4:51:14 PM */
        public static long updatedMS = 1272885674668L;
        static X_AD_TextTemplate()
        {
            Table_ID = Get_Table_ID("AD_TextTemplate");
        }
        /** AD_Table_ID=1000143 */
        public static int Table_ID;

        /** TableName=AD_TextTemplate */
        public static String Table_Name = "AD_TextTemplate";

        protected static KeyNamePair model = new KeyNamePair(Table_ID, "AD_TextTemplate");

        protected Decimal accessLevel = new Decimal(4);
        /** AccessLevel
        @return 4 - System 
        */
        protected override int Get_AccessLevel()
        {
            return Convert.ToInt32(accessLevel.ToString());
        }
        /** Load Meta Data
        @param ctx context
        @return PO Info
        */
        protected override POInfo InitPO(Context ctx)
        {
            POInfo poi = POInfo.GetPOInfo(ctx, Table_ID);
            return poi;
        }
        /** Load Meta Data
        @param ctx context
        @return PO Info
        */
        protected override POInfo InitPO(Ctx ctx)
        {
            POInfo poi = POInfo.GetPOInfo(ctx, Table_ID);
            return poi;
        }
        /** Info
        @return info
        */
        public override String ToString()
        {
            StringBuilder sb = new StringBuilder("X_AD_TextTemplate[").Append(Get_ID()).Append("]");
            return sb.ToString();
        }
        /** Set AD_TextTemplate_ID.
        @param AD_TextTemplate_ID AD_TextTemplate_ID */
        public void SetAD_TextTemplate_ID(int AD_TextTemplate_ID)
        {
            if (AD_TextTemplate_ID < 1) throw new ArgumentException("AD_TextTemplate_ID is mandatory.");
            Set_ValueNoCheck("AD_TextTemplate_ID", AD_TextTemplate_ID);
        }
        /** Get AD_TextTemplate_ID.
        @return AD_TextTemplate_ID */
        public int GetAD_TextTemplate_ID()
        {
            Object ii = Get_Value("AD_TextTemplate_ID");
            if (ii == null) return 0;
            return Convert.ToInt32(ii);
        }
        /** Set HTML.
        @param IsHtml Text has HTML tags */
        public void SetIsHtml(Boolean IsHtml)
        {
            Set_Value("IsHtml", IsHtml);
        }
        /** Get HTML.
        @return Text has HTML tags */
        public Boolean IsHtml()
        {
            Object oo = Get_Value("IsHtml");
            if (oo != null)
            {
                if (oo.GetType() == typeof(bool)) return Convert.ToBoolean(oo);
                return "Y".Equals(oo);
            }
            return false;
        }
        /** Set Mail Text.
        @param MailText Text used for Mail message */
        public void SetMailText(String MailText)
        {
            Set_Value("MailText", MailText);
        }
        /** Get Mail Text.
        @return Text used for Mail message */
        public String GetMailText()
        {
            return (String)Get_Value("MailText");
        }
        /** Set Name.
        @param Name Alphanumeric identifier of the entity */
        public void SetName(String Name)
        {
            if (Name != null && Name.Length > 60)
            {
                log.Warning("Length > 60 - truncated");
                Name = Name.Substring(0, 60);
            }
            Set_Value("Name", Name);
        }
        /** Get Name.
        @return Alphanumeric identifier of the entity */
        public String GetName()
        {
            return (String)Get_Value("Name");
        }
        /** Set Subject.
        @param Subject Email Message Subject */
        public void SetSubject(String Subject)
        {
            if (Subject != null && Subject.Length > 50)
            {
                log.Warning("Length > 50 - truncated");
                Subject = Subject.Substring(0, 50);
            }
            Set_Value("Subject", Subject);
        }
        /** Get Subject.
        @return Email Message Subject */
        public String GetSubject()
        {
            return (String)Get_Value("Subject");
        }
    }
}
